﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WuDada.Core.SystemApplications;
using WuDada.Core.SystemApplications.Service;
using WuDada.Core.SystemApplications.Domain;
using System.Text;

public partial class Main : System.Web.UI.MasterPage
{
    private SystemFactory m_SystemFactory;
    private ISystemService m_SystemService;
    private int m_HeadMeta = 1;

    protected void Page_Load(object sender, EventArgs e)
    {
        m_SystemFactory = new SystemFactory();
        m_SystemService = m_SystemFactory.GetSystemService();

        if (!Page.IsPostBack)
        {
            HeadMeta();
        }
    }

    private void HeadMeta()
    {
        StringBuilder sb = new StringBuilder();
        SystemParamVO systemParamVO = m_SystemService.GetSystemParamById(m_HeadMeta);
        string title = systemParamVO.PageTitle;
        string description = systemParamVO.PageDescription;
        string keyWord = systemParamVO.PageKeyWord;
        string googleAnalytics = systemParamVO.GoogleAnalytics;

        if (!string.IsNullOrEmpty(title))
        {
            sb.Append(string.Format("<title>{0}</title>", title));
        }

        if (!string.IsNullOrEmpty(description))
        {
            sb.Append(string.Format("<META NAME=\"Description\" CONTENT=\"{0}\">", description));
        }

        if (!string.IsNullOrEmpty(keyWord))
        {
            sb.Append(string.Format("<META NAME=\"KeyWords\" CONTENT=\"{0}\">", keyWord));
        }

        sb.Append(googleAnalytics);

        ltlMeta.Text = sb.ToString();
    }
}
